#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

class solution {
   public:
    int mining(vector<int> &pos, int m) {
        const int maxm = 2e6 + 10;
        vector<int> left_gain(maxm, 0);
        vector<int> right_gain(maxm, 0);
        int max_gain = 0, origin_gain = 0;
        for (auto it = pos.begin(); it != pos.end(); it++) {
            if (*it > 0)
                right_gain[*it]++;
            else if (*it < 0)
                left_gain[-*it]++;
            else
                origin_gain++;
        }

        for (int i = 1; i <= m; i++)
            right_gain[i] += right_gain[i - 1], left_gain[i] += left_gain[i - 1];

        for (int i = 0; i <= m; i++) {
            // max_gain=max(max_gain)
            max_gain = max(max_gain, origin_gain + right_gain[i] + (m - i - i > 0 ? left_gain[m - i - i] : 0));
            max_gain = max(max_gain, origin_gain + left_gain[i] + (m - i - i > 0 ? right_gain[m - i - i] : 0));
        }

        return max_gain;
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> pos(n);
    solution s;
    for (int i = 0; i < n; i++) cin >> pos[i];

    cout << s.mining(pos, m);
}